<%@ page language="java" import="java.util.*"contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="crm.control.ProductControl" %>
<%@ page import="crm.model.Product_system" %>
<%@ page import="crm.util.ParamUtil"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>product_system_add_do.jsp</title>
  </head>
  
  <body>
       <%
            request.setCharacterEncoding("UTF-8");
            Product_system productSystem=new Product_system();
            
            
            
            String system_name=ParamUtil.getString(request,"product_system_name");
            productSystem.setSystem_name(system_name);
            
            String system_number=ParamUtil.getString(request,"product_system_number");
            productSystem.setSystem_number(system_number);
            
            String system_develope_department=ParamUtil.getString(request,"product_system_develope_department","");
            productSystem.setDevelope_department(system_develope_department);
            
            String system_developer=ParamUtil.getString(request,"product_system_developer","");
            productSystem.setDeveloper(system_developer);
            
            String system_price=ParamUtil.getString(request,"product_system_price","");
            productSystem.setPrice(system_price);
            
            
            String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
            String system_create_time=ParamUtil.getString(request,"product_system_create_time",date);
            productSystem.setCreate_time(system_create_time);
            
            String system_description=ParamUtil.getString(request,"product_system_description","无");
            productSystem.setDescription(system_description);
            
            if(productSystem.getSystem_number()==null){ 
            %>
            <script type="text/javascript">
            window.alert("系统编号不能为空");
            window.location.href="product_system_add.jsp";
            </script>
            <%}else if(ProductControl.systemNameIsExist(system_name)){
            %>
            <script type="text/javascript">
            window.alert("系统名重复！添加失败");
            window.location.href="product_system_add.jsp";
            </script>   
            <%}else if(ProductControl.systemNumberIsExist(system_number)){
            %>
            <script type="text/javascript">
            window.alert("编号重复！添加失败");
            window.location.href="product_system_add.jsp";
            </script>
            <%}else if(ProductControl.addProductSystem(productSystem)){
            %>
           <script type="text/javascript">
if (window.confirm("添加商品成功，是否继续添加？"))
	window.location.href = "product_system_add.jsp";
else
	window.location.href = "product_system.jsp";
           </script>
           <%
           }
           %>
  </body>
</html>
